package d8_tttt;

import java.util.List;
import java.util.Random;

public class draw extends Thread {
    private List<String> gift;
    private String name;
    private int count;
    public draw(List<String> g, String name) {
        super(name);
        this.gift = g;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    @Override
    public void run() {
        Random random = new Random();
        while (true) {
            synchronized (gift) {
                    if (gift.size() < 11) {
                        break;
                    }
                    System.out.println(Thread.currentThread().getName() + "发出了: " + gift.get(random.nextInt(gift.size())));
                    gift.remove(random.nextInt(gift.size()));
                    count++;
            }
        }
    }

}
